import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 厨余登记信息 */
export interface RecipeFoodWaste {
  id: number // 编号
  mealType?: string // 餐别
  classId?: number // 班级ID
  schoolCode: string // 园区
  stapleFoodWaste: number // 主食剩余量（kg）
  sideDishWaste: number // 副食剩余量（kg）
  wasteReason: string // 剩余餐原因
  recordDate: string | Dayjs // 记录日期
  sort?: number // 排序
  status?: number // 状态
}

// 厨余登记 API
export const RecipeFoodWasteApi = {
  // 查询厨余登记分页
  getRecipeFoodWastePage: async (params: any) => {
    return await request.get({ url: `/school/recipe-food-waste/page`, params })
  },

  // 查询厨余登记详情
  getRecipeFoodWaste: async (id: number) => {
    return await request.get({ url: `/school/recipe-food-waste/get?id=` + id })
  },
  // 根据月份查询每天厨余统计状态
  getWasteByMonth: async (month: string) => {
    return await request.get({ url: `/school/recipe-food-waste/get-by-month?month=${month}` })
  },
  // 根据日期查询厨余统计列表
  getWasteByDay: async (day: string) => {
    return await request.get({ url: `/school/recipe-food-waste/get-by-day?day=${day}` })
  },
  // 新增厨余登记
  createRecipeFoodWaste: async (data: RecipeFoodWaste) => {
    return await request.post({ url: `/school/recipe-food-waste/create`, data })
  },

  // 修改厨余登记
  updateRecipeFoodWaste: async (data: RecipeFoodWaste) => {
    return await request.put({ url: `/school/recipe-food-waste/update`, data })
  },

  // 删除厨余登记
  deleteRecipeFoodWaste: async (id: number) => {
    return await request.delete({ url: `/school/recipe-food-waste/delete?id=` + id })
  },

  /** 批量删除厨余登记 */
  deleteRecipeFoodWasteList: async (ids: number[]) => {
    return await request.delete({
      url: `/school/recipe-food-waste/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出厨余登记 Excel
  exportRecipeFoodWaste: async (params) => {
    return await request.download({ url: `/school/recipe-food-waste/export-excel`, params })
  }
}
